//
//  ZYCodeViewController.m
//  ZYOils
//
//  Created by 段新瑞 on 2019/9/24.
//  Copyright © 2019 Mr.Xr. All rights reserved.
//

#import "ZYCodeViewController.h"
#import "ZYCodeContentView.h"

@interface ZYCodeViewController ()

@property(nonatomic, strong) UIScrollView *scrollView;

@property(nonatomic, strong) UIView *contentView;

@property(nonatomic, strong) ZYCodeContentView *codeContentView;

@end

@implementation ZYCodeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"扫码收款";
    
    [self customUI];
}


- (void)customUI {
    [self.view addSubview:self.scrollView];
    [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.view);
    }];
    
    [self.scrollView addSubview:self.contentView];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.scrollView);
        make.width.mas_equalTo(self.scrollView.mas_width);
        make.height.mas_equalTo(self.scrollView.mas_height).mas_equalTo(1);
    }];
    
    [self.contentView addSubview:self.codeContentView];
    [self.codeContentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(7);
        make.right.mas_equalTo(-7);
        make.top.mas_equalTo(5);
        make.height.mas_equalTo(300);
    }];
    
    NSDictionary *dict = @{@"amount": self.price,
                           @"oilUnit": self.model.neePrice,
                           @"companyName": ZYUserInfoModel.sharedInfoModel.userModel.companyName,
                           @"userName": ZYUserInfoModel.sharedInfoModel.userModel.userName,
                           @"payeeId": ZYUserInfoModel.sharedInfoModel.userModel.userId,
                           @"oilName": self.model.oilName,
                           @"managerId": ZYUserInfoModel.sharedInfoModel.userModel.managerId,
                           @"discount": @"????",
                           @"companyId": ZYUserInfoModel.sharedInfoModel.userModel.companyId};
    self.codeContentView.jsonStr = [dict mj_JSONString];
    
}

#pragma mark - 懒加载
- (UIScrollView *)scrollView {
    if (_scrollView == nil) {
        _scrollView = [UIScrollView new];
    }
    return _scrollView;
}

- (UIView *)contentView {
    if (_contentView == nil) {
        _contentView = [UIView new];
        _contentView.backgroundColor = BACKGROUNDCOLOR;
    }
    return _contentView;
}

- (ZYCodeContentView *)codeContentView {
    if (_codeContentView == nil) {
        _codeContentView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([ZYCodeContentView class]) owner:nil options:nil] lastObject];
    }
    return _codeContentView;
}

@end
